package com.pcbly.web.components.utils.pool;

import java.util.HashMap;
import java.util.Map;

public class SimpleCachePool {
	private static SimpleCachePool _instance = null;
	private static int _SIZE = 100000;
	private Map<String, Object> _pool;

	private SimpleCachePool() {
		_pool = new HashMap<String, Object>(_SIZE);
	}

	public SimpleCachePool getInstance() {
		if (_instance == null) {
			synchronized (this) {
				_instance = new SimpleCachePool();
			}
		}
		return _instance;
	}

	private Object _get(String id) {
		return _pool.get(id);
	}

	private void _put(String key, Object obj) {
		_pool.put(key, obj);
	}

	private Object _remove(String key) {
		return _pool.remove(key);
	}

	public static Object get(String key) {
		return _instance._get(key);
	}

	public static void put(String key, Object obj) {
		_instance._put(key, obj);
	}

	public static Object remove(String key) {
		return _instance._remove(key);
	}
}
